package fileModel;

import java.io.File;
import java.io.IOException;
import java.util.Observable;
import java.util.Observer;
import java.util.Queue;
import java.util.Scanner;



public class FileManager implements Observer{
	
	FileData data;
	Queue<Tag> tagQueue;
	
	
	
	private void find() {
		
		//FindTask findTask;

	}
	
	private void tag() {
		

	}

	@Override
	/**
	 * The method get updates from the osListenr abut changes at the dropbox folder.
	 */
	public void update(Observable o, Object arg) {

		String event;
		String path;
		
		//Separate the string arg1 to the event and the path.
		Scanner s=new Scanner((String)arg);
		s.useDelimiter(" ");
		event = s.next();
		path = s.next();
	
		System.out.format("FileManager =    %s:   %s\n", event, path);
		
		//Create a file from that path.
		File file = new File(path);
		
	/*	System.out.println("isFile = "+file.isFile());
		System.out.println("isDirectory = "+file.isDirectory());
		System.out.println("isAbsolute = "+file.isAbsolute());
		System.out.println("isHidden = "+file.isHidden());*/
		
		//If the file is not a directory, tag the file.
		if(!file.isDirectory()){
			
			Tag tagTask = new Tag(event, path, file);
			try {
				tagTask.tagTheFile();
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}	
		}
		
	}
	
	

}
